import { createRouter, createWebHistory, createWebHashHistory, RouteRecordRaw } from 'vue-router';
import Layout from '@/layout/index.vue';
import {pages} from "./pages/index"
import {getStore} from "@/utils/util/store"

// 静态路由
export const constantRoutes: Array<RouteRecordRaw> = [
    ...pages
]

const router = createRouter({
  history: createWebHashHistory(), // hash模式：createWebHashHistory，history模式：createWebHistory
  scrollBehavior: () => ({
    top: 0
  }),
  routes: constantRoutes
})

router.beforeEach((to, from, next) => {
  // if(!getStore({
  //   name: 'access_token'
  // })){
  //   next("/login")
  // }else{
  //   next("/login")
  // }
  next()
})
export default router
